package com.service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;

import com.dao.ArchiveDao;
import com.pojo.Archive;
import com.util.MySqlSessionFactory;

public class ArchiveService {
	SqlSession session = MySqlSessionFactory.getSqlSession();
	ArchiveDao dao = session.getMapper(ArchiveDao.class);

	public void add(@Param("archive_id") String archive_id,
			@Param("identity") String identity, @Param("name") String name,
			@Param("gender") String gender, @Param("birthday") String birthday,
			@Param("date_retire1") String date_retire1,
			@Param("date_retire2") String date_retire2, @Param("sp") String sp,
			@Param("fc") String fc, @Param("title") String title,
			@Param("seniority") String seniority) {
		dao.add(archive_id, identity, name, gender, birthday, date_retire1,
				date_retire2, sp, fc, title, seniority);
		session.commit();
	}
	
	public List<Archive> query(@Param("id") String id,
			@Param("archive_id") String archive_id,
			@Param("identity") String identity, @Param("name") String name,
			@Param("gender") String gender, @Param("birthday") String birthday,
			@Param("date_retire1") String date_retire1,
			@Param("date_retire2") String date_retire2, @Param("sp") String sp,
			@Param("fc") String fc, @Param("title") String title,
			@Param("seniority") String seniority) {
		return dao.query(id, archive_id, identity, name, gender, birthday,
				date_retire1, date_retire2, sp, fc, title, seniority);
	}

	public List<Archive> queryone(@Param("search") String search) {
		return dao.queryone(search);
	}
	
	public Map<String, Object> lastId(){
		return dao.lastId();
		
	}

	public List<Archive> query_one(@Param("id") String id) {
		return dao.query_one(id);
	}

	public void update(@Param("id") String id, @Param("name") String name,
			@Param("gender") String gender, @Param("birthday") String birthday,
			@Param("date_retire1") String date_retire1,
			@Param("date_retire2") String date_retire2, @Param("sp") String sp,
			@Param("fc") String fc, @Param("title") String title,
			@Param("seniority") String seniority) {
		dao.update(id, name, gender, birthday, date_retire1, date_retire2, sp,
				fc, title, seniority);
		session.commit();
	}

	public List<Map<String, Object>> queryliu(@Param("users_id") String users_id) {
		return dao.queryliu(users_id);
	}

	public List<Map<String, Object>> queryadd(@Param("users_id") String users_id) {
		return dao.queryadd(users_id);
	}

	public List<Map<String, Object>> querycount(@Param("date1") String date1,@Param("date2") String date2) {
		return dao.querycount(date1,date2);
	}

}
